﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.DeathModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DeathModelCommandHamdier
{
    public class DeathEagDeleteCommandHandler : IRequestHandler<DeathEagDeleteCommand, Results<int>>
    {
        private readonly iDeathModelService _iDeathModelService;

        public DeathEagDeleteCommandHandler(iDeathModelService deathModelService)
        {
            _iDeathModelService = deathModelService;
        }
        /// <summary>
        /// 处理删除命令，执行删除操作
        /// </summary>
        /// <param name="request">删除命令请求对象，包含要删除的记录的信息</param>
        /// <param name="cancellationToken">取消操作的令牌</param>
        /// <returns>
        /// 表示操作结果的泛型结果对象，包含一个整数值表示删除操作受影响的记录数
        /// </returns>
        public async Task<Results<int>> Handle(DeathEagDeleteCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _iDeathModelService.Delete(request.Id);
                return Results<int>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
